package org.dk.service.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.dk.mapper.TbBrandMapper;
import org.dk.pageInfo.PageInfo2;
import org.dk.pojo.TbBrand;
import org.dk.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
@com.alibaba.dubbo.config.annotation.Service
public class BrandServiceImpl implements BrandService {

    @Autowired
    private TbBrandMapper tbBrandMapper;
    @Override
    public PageInfo2<TbBrand> selectBrand(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        PageInfo<TbBrand> pageInfo = new PageInfo<>(tbBrandMapper.selectByExample(null));
        PageInfo2<TbBrand> pageInfo1 = new PageInfo2();
        pageInfo1.setPageNum(pageInfo.getPageNum());
        pageInfo1.setPageSize(pageInfo.getSize());
        pageInfo1.setTotal(pageInfo.getTotal());
        pageInfo1.setList(pageInfo.getList());
        pageInfo1.setLastPage(pageInfo.getPages());
        return pageInfo1;
    }

    @Override
    public Boolean insertinto(TbBrand tbBrand) {
        return 0 > tbBrandMapper.insertSelective(tbBrand);
    }

    @Override
    public Boolean deleteByid(Long id) {
        return 0 > tbBrandMapper.deleteByPrimaryKey(id);
    }

    @Override
    public TbBrand updata(Long id) {
        return tbBrandMapper.selectByPrimaryKey(id);
    }

    @Override
    public Boolean updatas(TbBrand tbBrand) {
        return 0 > tbBrandMapper.updateByPrimaryKeySelective(tbBrand);
    }

    @Override
    public List<TbBrand> selevt() {
        return tbBrandMapper.selectByExample(null);
    }
}
